/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Curriculums;

/**
 *
 * @author Cesar
 */

import java.util.ArrayList;
import java.util.List;
import java.sql.*;

public class Almacenados {
    static String bd = "bitacoraelectronica";
    static String login = "root";
    static String password = "A74543";
    static String url = "jdbc:mysql://localhost/"+bd;
    
    Connection conn = null;
            
    public Almacenados(){
        try {
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            conn = DriverManager.getConnection(url,login,password);
            if (conn != null) {
                System.out.println("Conexión a base de datos "+url+" ... Ok");
            }
        }
        catch (Exception e) {
                System.out.println(e);
                System.exit(0);
        }
        
    }
    
    public Object[] getItems() {
        List<String> list = new ArrayList<String>();
        try{
            Statement s = conn.createStatement();
            ResultSet rs = s.executeQuery("select Nombre from USUARIO U, PROFESOR P"
                    + " where U.username = P.usernameprof");
            while (rs.next())
            {
                list.add( rs.getString("Nombre"));
            }
        }
        catch (Exception e) {
                System.out.println(e);
                System.exit(0);
        }
        return list.toArray();
    }
}
